<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>确认订单</title>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1" />
<meta name="format-detection" content="telephone=no, email=no" />
<link rel="stylesheet" href="{{ url('/common/mobile-common/common.css') }}">		
<link rel="stylesheet" href="{{ url('/mobile/css/order/common.css') }}">		
<link rel="stylesheet" href="{{ url('/mobile/css/order/ordercomit.css') }}">	
<script src="{{ url('mobile/js/jquery-1.8.3.min.js') }}"></script>
<script src="{{ url('/common/mobile-common/hmt.js') }}"></script>
</head>
<body>
	<div class="abouts">
		<div class="wrap-cont clearfix">
				<!--收货地址-->
				<a href="{{url('wap/receiver')}}" class="dv-a"><div class="address clearfix">
					<img src="{{ url('mobile/images/addreee.png') }}" class="dw-icon">
					<p>
						<span class="dz1">{{$res->dname}}</span>
						<span class="dz2">{{$res->dphone}}</span>						
						<em>{{$res->province}}&nbsp{{$res->city}}&nbsp{{$res->daddress}}</em>
					</p>
					<a class="aaa"><img src="{{ url('mobile/images/more-icon.png') }}"></a>
					<img src="{{ url('mobile/images/linee.png') }}" class="linee">
				</div>
				</a>
				<!--end-->
				
				
				<!--订单内容-->
				<div class="contt">
					<div class="orders">
						<p class="order-num">
							<span class="logg"><img src="{{ url('mobile/images/logo2.png') }}"></span>
						</p>
						@foreach($goods as $v)
						<div class="orer-info clearfix">
							<img src="{{ config('config.picHostPrefix').$v->img }}">
							<p class="card-style">
								<span>{{$v->good_name}}</span>
								<em>类型:{{$v->type_name}}</em>
							</p>
							<p class="pri-num">
								<?php $memberVip = DB::table('members')->where('id',$memberId)->first();?>
								@if (!empty($v->vip_price)&&$memberVip->vip==1)
								<span>¥
									@if(!empty($v->discount)&&$v->discount!=0)
										<a>{{$v->vip_price*$v->discount}}</a>
									@else
										<a>{{$v->vip_price}}</a>
									@endif
								</span>
								@else
								<span>¥  
									@if(!empty($v->discount)&&$v->discount!=0)
									<a>{{$v->bprice*$v->discount}}</a>
									@else
									<a>{{$v->bprice}}</a>
									@endif
								</span>
								@endif
								<i></i>
								<em>x<a>{{$v->num}}</a></em>
							</p>
						</div>
						@endforeach
						<div class="ddan-in">
							<!--<ul>-->
							@if($effect||$effect2)
							<p class="hd clearfix">
								<span>参加活动</span>
								<em>@if($effect)
										<a data-id="1">满{{$effect}}减{{$cheap}}</a>
									@elseif($effect2)
										<a data-id="2">满{{$effect2}}送卡{{$num}}张</a>
									@endif
									<i><img src="{{ url('mobile/images/do-icon.png') }}"></i>
								</em>
							</p>
							<ul>
								@if($effect)
								<li data-id="1">满{{$effect}}减{{$cheap}}</li>
								@endif
								@if($effect2)
								<li data-id="2">满{{$effect2}}送卡{{$num}}张</li>
								@endif
							</ul>
							@endif
							<p class="yff clearfix">
								<span>运费</span>
								@if(!empty($res->postage))
								<em>¥<a>{{$res->postage}}</a></em>
								@else
								<em>¥<a>0</a></em>
								@endif
							</p>
							@if($effect)
							<p class="yhh clearfix">
								<span>优惠</span>
								<em class="yh-em">-¥<a>{{$cheap}}</a></em>
							</p>
							@endif
						<!--</ul>-->
						</div>
					</div>									
					<!--end-->
				</div>
				<!--end-->
				<p class="hji">
					<span>共{{count($goods)}}件商品</span>
					<em>合计:
						<i class="allAmount">
							@if($effect)
								¥{{$all-$cheap+$res->postage}}
							@else
								¥{{$all+$res->postage}}
							@endif
						</i>
					</em>
				</p>
				<div class="all-price clearfix">
						<p>
							<span>合计: <i class="allAmount">
									@if($effect)
										¥{{$all-$cheap+$res->postage}}
									@else
										¥{{$all+$res->postage}}
									@endif
								</i></span>
							<a href="javascript:void(0)" class="comopt">提交订单</a>								
						</p>
					</div>
				
		</div>
	</div>
	<script>
		$(function(){
			//选择活动
			$(".ddan-in p em a").on("click",function(){
				$(".ddan-in ul").toggle();
			});
			$(".ddan-in ul li").on("click",function(){
				var id = $(this).data('id');
				var liTxt=$(this).text();
				$(".ddan-in p em a").text(liTxt);
				$(".ddan-in p em a").attr('data-id',id);
				$(".ddan-in ul").hide();
				if (id==1) {
					var a = "-¥{{$cheap}}";
					$(".yh-em").text(a);
					$(".allAmount").text("¥{{$all-$cheap}}");
				} else if(id==2){
					var a = "送卡{{$num}}张";
					$(".yh-em").text(a);
					$(".allAmount").text("¥{{$all}}");
				}
			});

			//提交订单
			$(".comopt").click(function(){
				var typeId = $(".ddan-in p em a").data('id');
				if (!"{{$res->dname}}") {
					alert("请选择收货地址！")
				} else {
					$.post("{{ url('wap/order/finalOrder')}}",{typeId:typeId},function(data){
						if(data.success){
							window.location.href="{{url('wap/order/payWay/'.$res->id)}}";
						}else{
							alert(data.msg)
						}
					});
				}
			});

			//购买数量增加减少
       var t=$("#buyNum");
		t.on("change",function(){  
			if(t.val().replace(/[^0-9.]/g,'')){
			}else{
				alert("请输入正确的数值！");
				t.val(1);
			} 
		});
    	$("#add").on("touchstart",function(){
    		if(!(t.val().replace(/[^0-9.]/g,''))){
    			t.val(1);
    		}
    		else{
        		$("#reduce").css("cursor","pointer");
        		t.val(parseInt(t.val())+1);
//				if(t.val()>=7){
//				$("#add").css("cursor","not-allowed");  
//				$(".xz-num").show();
//				t.val(7);
//				$(".xz-num i").text(t.val());
//			}
        	}
        });
        $("#reduce").click(function(){ 
        	if(!(t.val().replace(/[^0-9.]/g,''))){
    			t.val(1);
    		}
    		else{
    			$("#reduce").css("cursor","pointer"); 
				t.val(parseInt(t.val())-1);
        		if(t.val()<=1){
        		t.val(1);
        		$("#reduce").css("cursor","not-allowed");    		
        	}
    		}         	       
        });
		})
		window.onload=function(){
			var dz1=$(".address .dz1").text();
			var dz2=$(".address .dz2").text();
			var dz3=$.trim($(".address em").text());
			if(dz1=='' && dz2=='' &&dz3 ==''){
				$(".address .dz1").text('请输入收货地址');
				$(".address .dz1").css("line-height","33px");
			}
			if("{{count($goods)}}"==0){
				$(".hji em .allAmount").text(0);
			}
		};
	</script>
</body>
</html>
